<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Register</title>
<style type="text/css">
	body{
		width: 98%;
		height: 100vh;
		display: flex;
		flex-flow: column;
		justify-content: center;
	}
	.register{
		width: 300px;
		height: auto;
		margin: 0px auto;
		border-radius: 5px;
		box-shadow: 0px 0px 15px black;
	}
</style>
</head>
<body>
	<div class="register">
	<form action="register.action" method="post">
		<table border="0" cellspacing="10" cellpadding="3">
			<caption>Register</caption>
			<tr>
				<td>用户名</td>
				<td>
					<input type="text" name="newone.name" placeholder="用户名" required /> 
				</td>
			</tr>
			<tr>
				<td>
					密码：
				</td>
				<td>
					<input type="password"  name="newone.password"  placeholder="密码" required />
				</td>
			</tr>
			<tr>
				<td>确认密码：</td>
				<td>
					<input type="password" name="repassword" placeholder="确认密码" required />
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<s:if test="#session['ERROR']">
						<span style="color:red">
							<s:property value="#session['ERROR'].getPassword()"/>
						</span>
						<% session.removeAttribute("ERROR"); %>
					</s:if>
				</td>
			</tr>
			<tr>
				<td>用户类型：</td>
				<td>
					<select name="newone.role">
						<option value="true">普通用户</option>
						<option value="false">管理员</option>
					</select>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<input type="submit" value="注册"  />
				</td>
			</tr>
		</table>
		</form>
	</div>
	
	<s:if test="#session['status']==true">
		<script type="text/javascript">
			alert("注册成功！！！"+"\n"+"你的登录ID：'"+${sessionScope.user.ID}+"'\n"+"你的登录密码："+"'"+${sessionScope.user.password}+"'");
			window.location.href="login.jsp";
		</script>
		<%
			session.setAttribute("status", false);
			session.removeAttribute("user");
		%>
	</s:if>
</body>
</html>